import http from './http';

const API_URL = 'http://localhost:8080/api';

// 获取所有用户（管理员功能）
export const getAllUsers = async (page = 0, size = 10) => {
  try {
    const response = await http.get(`/users?page=${page}&size=${size}`);
    return response;
  } catch (error) {
    return error;
  }
};

// 获取当前用户信息
export const getCurrentUserInfo = async () => {
  try {
    const response = await http.get('/users/me');
    return response;
  } catch (error) {
    return error;
  }
};

// 更新用户状态（启用/禁用）
export const updateUserStatus = async (userId, status) => {
  try {
    const response = await http.put(`/users/${userId}/status?status=${status}`);
    return response;
  } catch (error) {
    return error;
  }
};

// 更新个人信息
export const updateProfile = async (userData) => {
  try {
    const response = await http.put('/users/profile', userData);
    return response;
  } catch (error) {
    return error;
  }
};

// 修改密码
export const changePassword = async (passwordData) => {
  try {
    const response = await http.put('/users/password', passwordData);
    return response;
  } catch (error) {
    return error;
  }
}; 